package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.base.param.BaseParam;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.entity.GatewaySceneConfig;
import cn.stylefeng.guns.modular.gridsystem.model.param.GatewaySceneConfigParam;
import cn.stylefeng.guns.modular.gridsystem.model.param.GatewaySceneParam;
import cn.stylefeng.guns.modular.gridsystem.service.GatewaySceneService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 网关场景表 控制器
 *
 * @author: zxw
 * @date: 2022/11/08 16:22
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/gatewayScene")
public class GatewaySceneController {

    private final GatewaySceneService gatewaySceneService;

    /**
     * 分页查询网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @GetMapping("/page")
    @BusinessLog(title = "网关场景表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(GatewaySceneParam param) {
        return new SuccessResponseData(gatewaySceneService.page(param));
    }

    /**
     * 分页查询场景关联模板
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @GetMapping("/pageTemplate")
    @BusinessLog(title = "网关场景表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData pageTemplate(GatewaySceneParam param) {
        return new SuccessResponseData(gatewaySceneService.pageTemplate(param));
    }

    /**
     * 获取全部网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @GetMapping("/list")
    @BusinessLog(title = "网关场景表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(GatewaySceneParam param) {
        return new SuccessResponseData(gatewaySceneService.list(param));
    }

    /**
     * 查看详情网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @GetMapping("/detail")
    @BusinessLog(title = "网关场景表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(GatewaySceneParam.detail.class) GatewaySceneParam param) {
        return new SuccessResponseData(gatewaySceneService.detail(param));
    }


    /**
     * 查询场景推荐配置
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @GetMapping("/querySceneCfg")
    @BusinessLog(title = "查询场景推荐配置", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData querySceneCfg(@Validated(GatewaySceneParam.detail.class) GatewaySceneParam param) {
        return new SuccessResponseData(gatewaySceneService.querySceneCfg(param));
    }

    /**
     * 添加网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/add")
    @BusinessLog(title = "网关场景表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(GatewaySceneParam.add.class) GatewaySceneParam param) {
        gatewaySceneService.add(param);
        return new SuccessResponseData();
    }


    /**
     * 添加网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/addTemplate")
    @BusinessLog(title = "网关场景表_增加模板", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData addTemplate(@RequestBody @Validated(GatewaySceneParam.addTemplate.class) GatewaySceneParam param) {
        gatewaySceneService.addTemplate(param);
        return new SuccessResponseData();
    }

    /**
     * 删除网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/delete")
    @BusinessLog(title = "网关场景表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(GatewaySceneParam.delete.class) GatewaySceneParam param) {
        gatewaySceneService.delete(param);
        return new SuccessResponseData();
    }

    /**
     * 删除网关场景关联模板
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/deleteTemplate")
    @BusinessLog(title = "网关场景表_删除模板", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData deleteTemplate(@RequestBody @Validated(GatewaySceneParam.deleteTemplate.class) GatewaySceneParam param) {
        gatewaySceneService.deleteTemplate(param);
        return new SuccessResponseData();
    }

    /**
     * 编辑网关场景表
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/edit")
    @BusinessLog(title = "网关场景表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(GatewaySceneParam.edit.class) GatewaySceneParam param) {
        gatewaySceneService.edit(param);
        return new SuccessResponseData();
    }

    /**
     * 编辑网关场景配置项
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/editConfig")
    @BusinessLog(title = "网关场景表_编辑网关场景配置项", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData editConfig(@RequestBody @Validated(BaseParam.edit.class) GatewaySceneConfigParam param) {
        gatewaySceneService.editConfig(param);
        return new SuccessResponseData();
    }

    /**
     * 网关场景_同步场景配置
     *
     * @author zxw
     * @date 2022/11/08 16:22
     */
    @PostMapping("/syncConfig")
    @BusinessLog(title = "网关场景_同步场景配置", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData syncConfig(@RequestBody @Validated(BaseParam.edit.class) GatewaySceneParam param) {
        gatewaySceneService.syncConfig(param);
        return new SuccessResponseData();
    }

}
